/**
 * 
 */
jQuery(function($) {
	customer.select.init({customerId:$("#customer_id").val()});
});

var customer= {
	select: {
	        init:function (params) {
	            var path=$("#context_hidden_id").val();
	            var customerId=params['customerId'];
	            $.ajax({
	                type:"get",
	                url:path+"/customer/queryList",
	                async:true,
	                dataType:"json",
	                success:function(result){
	                	if(result.success) {
	                		for (var i=0;i<result.data.length;i++){
	                			var label=result.data[i].companyName+"-"+result.data[i].fullName+"-"+result.data[i].tel;
	                			var value=result.data[i].id;
	                			if (value==customerId){
	                				$("#customer-select").append("<option value='"+value+"' selected='selected'>"+label+"</option>")
	                			}else{
	                				$("#customer-select").append("<option value='"+value+"'>"+label+"</option>")
	                			}
	                		}
	                	}else {
	                		$("#customer-select").append("<option value=''>获取数据失败</option>")
	                	}
	                    $(".customer-chosen-select").chosen();
	                }
	            });
	        }
	    }
	}